package com.ctshk.rpc.air.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctshk.common.dto.Result;
import com.ctshk.rpc.air.dto.AirProductReservationSettingsDTO;
import com.ctshk.rpc.air.entity.AirProductReservationSettings;
import com.ctshk.rpc.air.mapper.AirProductReservationSettingsMapper;
import com.ctshk.rpc.air.service.IAirProductReservationSettingsService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

/**
 * <p>
 * 机票产品预订设置 服务实现类
 * </p>
 *
 * @author lihang
 * @since 2021-03-05
 */
@DubboService
public class AirProductReservationSettingsServiceImpl extends ServiceImpl<AirProductReservationSettingsMapper, AirProductReservationSettings> implements IAirProductReservationSettingsService {

    @Override
    public Result<AirProductReservationSettingsDTO> getByProductId(Long productId) {
        AirProductReservationSettings one = super.getOne(Wrappers.<AirProductReservationSettings>lambdaQuery()
                .eq(AirProductReservationSettings::getAirProductId, productId));
        AirProductReservationSettingsDTO airProductReservationSettingsDTO = null;
        if (null != one) {
            airProductReservationSettingsDTO = new AirProductReservationSettingsDTO();
            BeanUtils.copyProperties(one, airProductReservationSettingsDTO);
        }
        return Result.success(airProductReservationSettingsDTO);
    }
}
